<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Jialeo\LaravelSchemaExtend\Schema;

class CreateFeishuHireList extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('feishu_hire_applications', function (Blueprint $table) {
            $table->id();
            $table->string('applicationId')->default('')->comment('投递id');
            $table->string('talentId')->default('')->comment('候选人 ID');
            $table->string('stageId')->default('')->comment('	阶段 ID');
            $table->string('stageName')->default('')->comment('阶段中文名字');
            $table->string('stageType')->default('')
                  ->comment('阶段类型 1筛选型2：评估型3：笔试型4：面试型5：Offer型6：待入职7：已入职8：其它类型255：系统默认');
            $table->unsignedTinyInteger('activeStatus')->default(0)
                  ->comment('活跃状态1：活跃2：非活跃，即为「已终止」3：全部');
            $table->unsignedTinyInteger('isLatest')->default(0)->comment('是否最新记录 1 是 0 否');
            $table->json('originalData')->default('')->comment('原始数据');

            $table->string('talentCreatorFsId')->default('')->comment('人才创建人飞书 ID');
            $table->string('talentCreatorFsName')->default('')->comment('人才创建人飞书 名字');
            $table->string('talentCreatorFsNickname')->default('')->comment('人才创建人飞书 花名');

            $table->unsignedInteger('createdAt')->default(0)->comment('阶段创建时间');
            $table->unsignedInteger('createdByUid')->default(0)->comment('创建人');
            $table->unsignedInteger('updatedAt')->default(0)->comment('阶段修改时间');
            $table->unsignedInteger('updatedByUid')->default(0)->comment('修改人');

            $table->index('stageType', 'idx_stageType');
            $table->index('applicationId', 'idx_applicationId');
            $table->index('talentId', 'idx_talentId');

            $table->collation = 'utf8mb4_general_ci';
            $table->comment   = '招聘阶段流程表';
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('feishu_hire_applications');
    }
}
